package com.hakim.wfb.web.controller.custom;

import com.hakim.wfb.admin.params.customer.GetCustomerOrderListPageParam;
import com.hakim.wfb.admin.params.customer.SendCustomerOrderParameter;
import com.hakim.wfb.admin.result.admin.CustomerOrderListView;
import com.hakim.wfb.customer.params.order.CancelOrderParameter;
import com.hakim.wfb.admin.service.api.OrderService;
import com.hakim.wfb.customer.params.order.SignOrderParameter;
import com.hakim.wfb.customer.service.PurchaseService;
import com.hkfs.fundamental.api.data.ListResultEx;
import com.hkfs.fundamental.api.data.ResultEx;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by lenovo on 2017/7/27.
 */
@RestController
@RequestMapping(value = "/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    @Autowired
    private PurchaseService purchaseService;

    @RequestMapping(value = "/get_customer_orders", name = "订单列表", method = RequestMethod.POST)
    public ListResultEx<CustomerOrderListView> getCustomerOrderList(GetCustomerOrderListPageParam parameter, HttpServletRequest request) {

        return orderService.getCustomerOrderList(parameter);
    }

    @RequestMapping(value = "/sendOrder", name = "订单发货", method = RequestMethod.POST)
    public ResultEx sendOrder(SendCustomerOrderParameter parameter, HttpServletRequest request) {

        return orderService.sendOrder(parameter);
    }

    @RequestMapping(value = "cancelOrder", name = "订单撤回", method = RequestMethod.POST)
    public ResultEx cancelOrder(CancelOrderParameter parameter, HttpServletRequest request) {
        return purchaseService.cancelOrder(parameter);
    }

    @RequestMapping(value = "signOrder", name = "订单签收", method = RequestMethod.POST)
    public ResultEx signOrder(SignOrderParameter parameter, HttpServletRequest request) {
        return orderService.signOrder(parameter);
    }
}
